// **************************************************************
// Com ++ Framework by the C++ World
// Please report defects: mailto:compp@cplusplusworld.com
// Please visit: http://www.cplusplusworld.com/socketlibrary.html
// **************************************************************

#ifndef GENCFG_H
#define GENCFG_H


#include <string>

namespace compp {

  // Comm
  const int StdCommWriteTimeout = 5000000;
  const int StdCommReadTimeout  = 5000000;
  const int StdCommFDAttached   = true;
  const int StdCommMaxNumBytesToRead  = 1024*1024;
  // Socket
  const int StdCommLingerTime   = 0;
  const int StdCommUseDNS       = true; 
  // SocketTcp
  const bool StdCommOptAsync         = false;
  const int  StdCommBacklog          = 5;
  const bool StdCommOptAsyncConnect  = false;
  const bool StdCommOptTcpNoDelay    = false;

  class GenCfg  {

    protected:

      static GenCfg *instance_;

      // ************************ Cfg Settings ************************

      // Comm
      int CommWriteTimeout ;
      int CommReadTimeout ;
      bool CommFDAttached;
      int MaxNumBytesToRead;

      // Socket
      int CommLingerTime ;
      bool CommUseDNS ;

      // SocketTcp
      bool CommOptAsync;
      bool CommOptAsyncConnect;
      bool CommOptTcpNoDelay;
      int  Backlog;


      // ************************ Cfg Settings ************************

    public:

      static GenCfg *Instance();  

      GenCfg();
      void FillDefaults();

      void SetCommWriteTimeout (int val);
      int  GetCommWriteTimeout ();

      void SetCommReadTimeout (int val);
      int  GetCommReadTimeout ();

      void SetCommFDAttached (bool val);
      bool GetCommFDAttached ();

      void SetCommOptAsync (bool val);
      bool GetCommOptAsync ();

      void SetCommOptAsyncConnect (bool val);
      bool GetCommOptAsyncConnect ();

      void SetCommLingerTime (int val);
      int  GetCommLingerTime ();

      void SetCommBacklog (int val);
      int  GetCommBacklog ();

      void SetCommUseDNS (bool val);
      bool GetCommUseDNS ();

      void SetCommMaxNumBytesToRead (int val);
      int GetCommMaxNumBytesToRead ();

      void SetCommOptTcpNoDelay (bool val);
      bool GetCommOptTcpNoDelay ();
  
};
}
#endif
